package letsjava.pattern.composite;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class CompositeEquipment extends Equipment {
	private int i = 0;
	private List equipment = new ArrayList();

	public CompositeEquipment(String name) {
		super(name);
	}

	public boolean add(Equipment equipment) {
		this.equipment.add(equipment);
		return true;
	}

	public double netPrice() {
		double netPrice = 0.;
		Iterator iter = equipment.iterator();
		while (iter.hasNext()) {
			netPrice += ((Equipment) iter.next()).netPrice();
		}
		return netPrice;
	}

	public double discountPrice() {
		double discountPrice = 0.;
		Iterator iter = equipment.iterator();
		while (iter.hasNext())
			discountPrice += ((Equipment) iter.next()).discountPrice();
		return discountPrice;
	}

	 
}
